﻿<%@ Page Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="ACM_GeneralLedger.aspx.cs" Inherits="KPIS.GERP.GAMS.APP.App_UI.Forms.ACM_GeneralLedger" %>
<%@ Register src="../UserControls/DatePicker.ascx" tagname="DatePicker" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>รายการบัญชีขั้นต้น</title>
    <link href="../CssClass.css" rel="stylesheet" type="text/css" />
    <script language="JavaScript" src="../Scripts/DatePicker.js" type="text/jscript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">

            function OpenWindow(id) {
                radopen("ACM_AdjustTransection.aspx?TranSeq=" + id, "ddddd");
            }
            function openPrintExcel(id) {
                window.open("PrintExcel.aspx?Id=" + id + "&Type=Ledger");
            }
        </script>
    </telerik:RadCodeBlock>

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="Panel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    
    <asp:Panel ID="Panel1" runat="server">
        <div class="DivControl" style="color: #FFFFFF; font-size: large; font-weight: bold;">
            &nbsp;&nbsp;&nbsp;&nbsp;รายการบัญชีขั้นต้น
        </div>
        <div class="DivBody">
            <table>
                <tr>
                    <td align="right" width="150px">
                        ประเภทบัญชีขั้นต้น :
                    </td>
                    <td>
                        <asp:RadioButtonList ID="rblTranType" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Text="รายวันทั่วไป" Value="G" Selected="True" />
                            <asp:ListItem Text="รายวันรับเงิน" Value="R" />
                            <asp:ListItem Text="รายวันจ่ายเงิน" Value="P" />
                            <asp:ListItem Text="ปรับปรุง" Value="A" />
                            <asp:ListItem Text="ทั้งหมด" Value="" />
                        </asp:RadioButtonList>
                    </td>
                </tr>
            </table>
            <table>
                <tr>
                    <td align="right" width="150px">
                        แหล่งเงิน :
                    </td>
                    <td align="left" width="300px">
                        <telerik:RadComboBox ID="ddlBgmSourceSeq" runat="server"
                            DataTextField="bgm_source_name" DataValueField="bgm_source_seq"
                            Filter="Contains" Width="280px">
                        </telerik:RadComboBox>
                    </td>
                    <td align="right" width="50px">
                        ปี :
                    </td>
                    <td align="left">
                        <telerik:RadNumericTextBox ID="txtBgmYear" runat="server"
                            MaxLength="4" MinValue="2500" MaxValue="2600"
                            NumberFormat-DecimalDigits="0" NumberFormat-GroupSizes="9" 
                            ShowSpinButtons="true"></telerik:RadNumericTextBox>
                    </td>
                </tr>
            </table>
            <table>
                <tr>
                    <td align="right" width="150px">
                        ตั้งแต่วันที่ :
                    </td>
                    <td align="left" width="300px">
                        <uc1:DatePicker ID="dpDateStart" runat="server" />
                    </td>
                    <td align="right" width="50px">
                        ถึง :
                    </td>
                    <td align="left">
                        <uc1:DatePicker ID="dpDateEnd" runat="server" />
                    </td>
                </tr>
            </table>
        </div>
        <div class="DivInfo" align="center">
            <asp:Button ID="cmdFilter" runat="server" Text="กรองข้อมูล" OnClick="cmdFilter_Click"></asp:Button>
        </div>
        <div class="DivInfo" align="center" id="divAddNew" visible="false" runat="server">
            <asp:Button ID="cmdAddNew" runat="server" Text="สร้างรายการปรับปรุงบัญชี" OnClientClick="OpenWindow('')"></asp:Button>
        </div>
        <div>
            <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="grdACMAccountAuto" runat="server" AutoGenerateColumns="false"
                AllowMultiRowEdit="false" AllowMultiRowSelection="true" ShowStatusBar="true" 
                Width="998px" AllowPaging="true" AllowFilteringByColumn="true" AllowSorting="true"
                GroupingSettings-GroupByFieldsSeparator="&nbsp;&nbsp;&nbsp;&nbsp;"
                GroupingSettings-GroupContinuedFormatString=""
                GroupingSettings-GroupContinuesFormatString=""
                GroupingSettings-GroupSplitFormat=""
                OnDetailTableDataBind="RadGrid1_DetailTableDataBind"
                OnNeedDataSource="grdACMAccountAuto_NeedDataSource" 
                OnItemDataBound="grdACMAccountAuto_ItemDataBound">
                <MasterTableView AllowMultiColumnSorting="True" Width="100%"
                    DataKeyNames="tran_seq" NoMasterRecordsText="< ไม่มีข้อมูล >" GroupsDefaultExpanded="false">
                    <DetailTables>
                        <telerik:GridTableView Width="100%" runat="server" ShowFooter="true" AllowPaging="false" AllowFilteringByColumn="false"
                            Caption="รายละเอียด" DataKeyNames="tran_dtls_seq">
                            <Columns>
                                <telerik:GridBoundColumn DataField="tran_dtls_seq" UniqueName="tran_dtls_seq" Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="tran_seq" UniqueName="tran_seq" Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="account_seq" UniqueName="account_seq" Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="dr_or_cr" Visible="false"
                                    HeaderText="เดบิต/เครดิต" UniqueName="dr_or_cr"
                                    FilterControlWidth="100%" AutoPostBackOnFilter="true"
                                    CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="100px"
                                    HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="account_code" 
                                    HeaderText="รหัสบัญชี" UniqueName="account_code" 
                                    FilterControlWidth="100%" AutoPostBackOnFilter="true"
                                    CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="150px"
                                    HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="account_name" 
                                    HeaderText="ชื่อบัญชี" UniqueName="account_name" 
                                    FilterControlWidth="100%" AutoPostBackOnFilter="true"
                                    CurrentFilterFunction="Contains" ShowFilterIcon="false" 
                                    HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center"
                                    FooterStyle-HorizontalAlign="Right"
                                    FooterText="รวม :">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="debit_amount" Aggregate="Sum"
                                    HeaderText="Dr" UniqueName="debit_amount" DataFormatString="{0:n2}"
                                    FilterControlWidth="100%" AutoPostBackOnFilter="true"
                                    CurrentFilterFunction="Contains" ShowFilterIcon="false" 
                                    HeaderStyle-Width="150px" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center"
                                    ItemStyle-HorizontalAlign="Right"
                                    FooterStyle-HorizontalAlign="Right">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="credit_amount" Aggregate="Sum"
                                    HeaderText="Cr" UniqueName="credit_amount" DataFormatString="{0:n2}"
                                    FilterControlWidth="100%" AutoPostBackOnFilter="true"
                                    CurrentFilterFunction="Contains" ShowFilterIcon="false" 
                                    HeaderStyle-Width="150px" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center"
                                    ItemStyle-HorizontalAlign="Right"
                                    FooterStyle-HorizontalAlign="Right">
                                </telerik:GridBoundColumn>
                            </Columns>
                        </telerik:GridTableView>
                    </DetailTables>
                    <Columns>
                        <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="35px" >
                        </telerik:GridClientSelectColumn> 

                        <telerik:GridBoundColumn DataField="bgm_year" UniqueName="bgm_year" Visible="false">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="record_status" UniqueName="record_status" Visible="false">
                        </telerik:GridBoundColumn>
                        <telerik:GridTemplateColumn UniqueName="edit" HeaderText="แก้ไข" Visible="false" AllowFiltering="false"
                            HeaderStyle-Font-Bold="true" HeaderStyle-Width="40" HeaderStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:ImageButton ID="btnEdit" runat="server" OnClientClick='<%# string.Format("return OpenWindow(\"{0}\");", Eval("tran_seq")) %>' 
                                    ImageUrl="~/App_UI/Images/Buttons/Edit.gif" ToolTip="แก้ไขข้อมูล" width="17px" />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn DataField="ref_type" UniqueName="ref_type" Visible="false">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="ref_seq" UniqueName="ref_seq" Visible="false" >
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="tran_seq" UniqueName="tran_seq" Visible="false">
                        </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="tran_type" UniqueName="tran_type" Visible="false">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="work_area_seq" UniqueName="work_area_seq" Visible="false">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="bgm_source_seq" UniqueName="bgm_source_seq" Visible="false">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="ref_no" 
                            HeaderText="เลขที่อ้างอิง" UniqueName="ref_no"
                            FilterControlWidth="100%" AutoPostBackOnFilter="true"
                            CurrentFilterFunction="Contains" ShowFilterIcon="false" 
                            HeaderStyle-Width="100px" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="tran_date" DataFormatString="{0:d}"
                            HeaderText="วันที่ทำรายการ" UniqueName="tran_date" AllowFiltering="false"
                            FilterControlWidth="100%" AutoPostBackOnFilter="true"
                            CurrentFilterFunction="Contains" ShowFilterIcon="false" 
                            HeaderStyle-Width="120px" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="tran_name" 
                            HeaderText="ชื่อรายการ" UniqueName="tran_name"
                            FilterControlWidth="100%" AutoPostBackOnFilter="true"
                            CurrentFilterFunction="Contains" ShowFilterIcon="false" 
                            HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center"><%--HeaderStyle-Width="200px"--%>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="amount"
                            HeaderText="จำนวนเงิน" UniqueName="amount" DataFormatString="{0:n2}"
                            FilterControlWidth="100%" AutoPostBackOnFilter="true"
                            CurrentFilterFunction="Contains" ShowFilterIcon="false" 
                            HeaderStyle-Width="150px" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center"
                            ItemStyle-HorizontalAlign="Right"
                            FooterStyle-HorizontalAlign="Right">
                        </telerik:GridBoundColumn>
                        <%--<telerik:GridBoundColumn DataField="remarks" 
                            HeaderText="หมายเหตุ" UniqueName="remarks"
                            FilterControlWidth="100%" AutoPostBackOnFilter="true"
                            CurrentFilterFunction="Contains" ShowFilterIcon="false" 
                            HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center"
                            HeaderStyle-Width="150px">
                        </telerik:GridBoundColumn>--%>
                        <telerik:GridBoundColumn DataField="record_status_name" 
                            HeaderText="สถานะ" UniqueName="record_status_name"
                            FilterControlWidth="100%" AutoPostBackOnFilter="true"
                            CurrentFilterFunction="Contains" ShowFilterIcon="false" 
                            HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center"
                            HeaderStyle-Width="100px"><%--HeaderStyle-Width="200px"--%>
                        </telerik:GridBoundColumn>
                        <telerik:GridTemplateColumn AutoPostBackOnFilter="true" AllowFiltering="false"
                            CurrentFilterFunction="Contains"
                            FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center"
                            HeaderText="ใบสำคัญลงบัญชี" ShowFilterIcon="false">
                            <ItemTemplate>
                                <asp:LinkButton ID="cmdPrintPopup" runat="server" CssClass="LinkButton"
                                    OnClientClick='<%# string.Format("return openPrintExcel(\"{0}\");", Eval("tran_seq")) %>'>
                                    <img alt="" id="imgPrint" runat="server" src="~/App_UI/Images/Buttons/Print1.gif" style="width: 1.5em; height: 1.5em;" />
                                </asp:LinkButton>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridTemplateColumn>
                    </Columns>
                    <PagerStyle Mode="NumericPages" AlwaysVisible="true" 
                        FirstPageToolTip="กลับหน้าแรก" LastPageToolTip="ไปหน้าสุดท้าย" 
                        NextPagesToolTip="หน้าถัดไป" NextPageToolTip="หน้าถัดไป" 
                        PrevPagesToolTip="ย้อนกลับ" PrevPageToolTip="ย้อนกลับ" />
                </MasterTableView>
                <GroupingSettings GroupByFieldsSeparator="&nbsp;&nbsp;&nbsp;&nbsp;" 
                    GroupContinuedFormatString="" GroupContinuesFormatString="" 
                    GroupSplitFormat="" />
                <ClientSettings EnableRowHoverStyle="True" EnablePostBackOnRowClick="false">
                    <Selecting AllowRowSelect="True" />
                    <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                </ClientSettings>
            </telerik:RadGrid>
        </div>
        <div class="DivInfo" align="center">
            <asp:Button ID="cmdPost" runat="server" Text="Post" OnClick="cmdPost_Click" />
            <asp:Label ID="lblSummary" runat="server" ForeColor="Red"></asp:Label>
        </div>
    </asp:Panel>
    <telerik:RadWindowManager runat="server" ID="RadWindowManager1" ReloadOnShow="true" Width="870px" Height="680px">
        <Windows>
            <telerik:RadWindow
                Title="รายการปรับปรุงบัญชี" 
                ID="ddddd"
                runat="server">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
</asp:Content>
